import React, { useEffect, useState } from 'react'
import { Row, Col, Input, Space, Button, Modal } from "antd";
import ModalSet from './components';
const AllSetoption = (props) => {
    const {
        data = {},
        index,
        onChange
    } = props
    const {
        option = [],
    } = data
    const [visible, setVisible] = useState(false)
    useEffect(() => {
        console.log(visible, '123')
    }, [visible])
    return <div>
        <Button onClick={() => setVisible(true)} type='link'>
            批量添加选项

        </Button>
        <ModalSet
            visible={visible}
            onOk={(e) => {
                onChange({
                    changeType: 'update',
                    data: {
                        ...data,
                        option: [...option, ...e.replace(/(\r\n)|\r|\n/g, '\n')
                            .split(/\n+/g)
                            .filter((item) => {
                                if (item) {
                                    return true;
                                } else {
                                    return false;
                                }
                            }).map(val => {
                                return {
                                    label: val
                                }
                            })]
                    },
                    index: index
                })

            }}
            onClose={() => {
                console.log('执行关闭')
                setVisible(false)
            }}></ModalSet>
    </div>
}
export default AllSetoption